package com.wrupple.muba.common.client;

import java.util.List;

import com.google.gwt.event.shared.HandlerRegistration;
import com.google.gwt.user.client.ui.ResizeComposite;
import com.google.gwt.view.client.HasData;
import com.google.gwt.view.client.Range;
import com.google.gwt.view.client.RangeChangeEvent.Handler;
import com.google.gwt.view.client.SelectionModel;

public class DelegateHasData<T> extends ResizeComposite implements HasData<T> {
	
	protected  HasData<T> hasData;
	
	public DelegateHasData() {
		super();
	}

	public DelegateHasData(HasData<T> delegate) {
		super();
		this.hasData=delegate;
	}

	@Override
	public HandlerRegistration addRangeChangeHandler(Handler handler) {
		return hasData.addRangeChangeHandler(handler);
	}

	@Override
	public HandlerRegistration addRowCountChangeHandler(com.google.gwt.view.client.RowCountChangeEvent.Handler handler) {
		return hasData.addRowCountChangeHandler(handler);
	}

	@Override
	public int getRowCount() {
		return hasData.getRowCount();
	}

	@Override
	public Range getVisibleRange() {
		return hasData.getVisibleRange();
	}

	@Override
	public boolean isRowCountExact() {
		return hasData.isRowCountExact();
	}

	@Override
	public void setRowCount(int count) {
		hasData.setRowCount(count);
	}

	@Override
	public void setRowCount(int count, boolean isExact) {
		hasData.setRowCount(count,isExact);
	}

	@Override
	public void setVisibleRange(int start, int length) {
		hasData.setVisibleRange(start, length);
	}

	@Override
	public void setVisibleRange(Range range) {
		hasData.setVisibleRange(range)
		;
	}

	@Override
	public HandlerRegistration addCellPreviewHandler(com.google.gwt.view.client.CellPreviewEvent.Handler<T> handler) {
		return hasData.addCellPreviewHandler(handler);
	}

	@Override
	public SelectionModel<? super T> getSelectionModel() {
		return hasData.getSelectionModel();
	}

	@Override
	public T getVisibleItem(int indexOnPage) {
		return hasData.getVisibleItem(indexOnPage);
	}

	@Override
	public int getVisibleItemCount() {
		return hasData.getVisibleItemCount();
	}

	@Override
	public Iterable<T> getVisibleItems() {
		return hasData.getVisibleItems();
	}

	@Override
	public void setRowData(int start, List<? extends T> values) {
		hasData.setRowData(start, values);
	}

	@Override
	public void setSelectionModel(SelectionModel<? super T> selectionModel) {
		hasData.setSelectionModel(selectionModel);
	}

	@Override
	public void setVisibleRangeAndClearData(Range range, boolean forceRangeChangeEvent) {
		hasData.setVisibleRangeAndClearData(range, forceRangeChangeEvent);
	}
	
	protected void setDelegate(HasData<T> delegate){
		this.hasData=delegate;
	}
}
